.TH std::filesystem::file_time_type 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::filesystem::file_time_type \- std::filesystem::file_time_type

.SH Synopsis
   Defined in header <filesystem>
   using file_time_type = std::chrono::time_point</*trivial-clock*/>;     \fI(since C++17)\fP
                                                                          \fI(until C++20)\fP
   using file_time_type =                                                 \fI(since C++20)\fP
   std::chrono::time_point<std::chrono::file_clock>;

   Represents file time.

   trivial-clock is an implementation-defined type that satisfies
   TrivialClock and is sufficient to represent the resolution and range   \fI(until C++20)\fP
   of the file time values offered by the filesystem.

.SH Example


// Run this code

 #include <chrono>
 #include <filesystem>
 #include <format>
 #include <fstream>
 #include <iostream>

 using namespace std::chrono_literals;

 int main()
 {
     auto p = std::filesystem::temp_directory_path() / "example.bin";
     std::ofstream{p.c_str()}.put('a'); // create file

     std::filesystem::file_time_type ftime = std::filesystem::last_write_time(p);
     std::cout << std::format("File write time is {}\\n", ftime);

     // move file write time 1 hour to the future
     std::filesystem::last_write_time(p, ftime + 1h);

     // read back from the filesystem
     ftime = std::filesystem::last_write_time(p);
     std::cout << std::format("File write time is {}\\n", ftime);

     std::filesystem::remove(p);
 }

.SH Possible output:

 File write time is 2023-09-04 19:33:24.702639224
 File write time is 2023-09-04 20:33:24.702639224

.SH See also

   last_write_time gets or sets the time of the last data modification
   \fI(C++17)\fP         \fI(function)\fP
